package tech.springboot.schedule.executorservice;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.time.LocalDateTime;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author pdai
 */
@SpringBootApplication
public class App {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(App.class, args);

        ScheduledExecutorService executorService = applicationContext.getBean(ScheduledExecutorService.class);

        executorService.scheduleAtFixedRate(()->{
            System.out.println(Thread.currentThread().getName() + "-->" +  LocalDateTime.now());
        }, 1000, 500, TimeUnit.MILLISECONDS);

    }

}
